home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 1.iso / ARGONET / PD / PROGRAMMING / DESKLIBC / SOURCES.ZIP / DeskLib / !DLSources / Libraries / Icon / c / GetFgCol < prev    next >
Text File  |  1994-05-29  |  2KB  |  50 lines

  1. /*
  2.     ####             #    #     # #
  3.     #   #            #    #       #          The FreeWare C library for 
  4.     #   #  ##   ###  #  # #     # ###             RISC OS machines
  5.     #   # #  # #     # #  #     # #  #   ___________________________________
  6.     #   # ####  ###  ##   #     # #  #                                      
  7.     #   # #        # # #  #     # #  #    Please refer to the accompanying
  8.     ####   ### ####  #  # ##### # ###    documentation for conditions of use
  9.     ________________________________________________________________________
  10.  
  11.     File:    Icon.GetFgCol.c
  12.     Author:  Copyright © 1994 Tim Browse
  13.     Version: 1.00 (05 Mar 1994)
  14.     Purpose: Retrieve the foreground colour of an icon.
  15. */
  16.  
  17. #include "DeskLib:Wimp.h"
  18. #include "DeskLib:WimpSWIs.h"
  19. #include "DeskLib:Icon.h"
  20. #include "DeskLib:Validation.h"
  21. #include "DeskLib:Str.h"
  22.  
  23.  
  24. int Icon_GetFgCol(icon_block *icon)
  25. {
  26.   int colour;
  27.  
  28.   /* Straightforward case first...*/
  29.   if (!icon->flags.data.font)
  30.     return icon->flags.data.foreground;
  31.   
  32.   /* Icon is anti-aliased - read font validation string colours */
  33.   colour = Validation_ScanString(icon->data.indirecttext.validstring, 
  34.                                  iconvalid_FONTCOLOURS);
  35.  
  36.   /* No colours specified - use default */
  37.   if (colour == 0)
  38.     return colour_BLACK;
  39.   
  40.   /* Decode second colour digit */
  41.   colour = Str_DecodeHex(icon->data.indirecttext.validstring[colour+1]);
  42.  
  43.   /* Limit to legal value */
  44.   if (colour == -1)
  45.     colour = colour_BLACK;
  46.  
  47.   return colour;
  48. }
  49.  
  50.